from django.contrib.auth.models import User
from django.core import serializers
from django.http import HttpResponse

def add(request):
    user = User.objects.create_user('sjgadd', 'sjgadd@localhost', 'sjgpwd')
    user.is_staff = True
    print(user)
    user.save()
    return HttpResponse('add success')

def update(request):
    u =User.objects.get(username__exact='sjgadd')
    u.set_password('mysjgpwd')
    u.is_staff = False
    u.save()
    return HttpResponse('update success')

def getall(request):
    allresult = User.objects.all()[0:5]
    print(allresult)
    data = serializers.serialize('json', allresult)
    return HttpResponse(data)